<template>
  <div class="main_container">
    <router-view v-slot="{ Component }">
      <keep-alive>
        <component :is="Component" v-if="isKeepAlive" />
      </keep-alive>
      <component :is="Component" v-if="!isKeepAlive" />
    </router-view>
  </div>
</template>
<script  setup>
import { computed, onBeforeMount, nextTick, provide, onMounted } from 'vue'
import { useRoute } from 'vue-router'
import { finIndexDetail, getSysConfig, getExchangeStocks } from '@/store/index.js'
import { showLoadingToast, closeToast } from 'vant'
import { t } from '@/languages'
const $route = useRoute()
// 是否使用keep-alive
const isKeepAlive = computed(() => $route?.meta?.keepAlive)
const whiteList = ['/login', '/register']

async function initAPPConfig() {
  if(!localStorage.getItem('exToken')) {
    return
  }
  showLoadingToast()
  await getSysConfig()
  await nextTick()
  await Promise.all([getExchangeStocks(10), finIndexDetail(10)])
  closeToast()
}

onBeforeMount((() => {
  if (!localStorage.getItem('lang')) {
    localStorage.setItem('lang', 'EN')
  }
}))
onMounted(() => {
  initAPPConfig()
})
provide('initAPPConfig', initAPPConfig)

</script>
<style lang="scss">
#app {
  width: 100%;
  height: 100%;
  .main_container {
    width: 100%;
    height: 100%;
    overflow-y: auto;
  }
}
</style>
